import { Pipe, PipeTransform } from '@angular/core';
import { UserWithdrawalAddressMobileList } from '../../../model';

@Pipe({
  name: 'userWithdrawalAddress'
})
export class UserWithdrawalAddressPipe implements PipeTransform {

  transform(value: UserWithdrawalAddressMobileList | string, list: UserWithdrawalAddressMobileList[]): string {
    if (value) {
      if (typeof value === 'string') {
        const data = list.find(v => v.tag === value);
        if (data) {
          return data.tag;
        } else {
          return '';
        }
      } else {
        return value.tag;
      }
    } else {
      return '';
    }
    // if (value) {
    //   return value.tag;
    // } else {
    //   return '';
    // }
  }

}
